package cn.wenlihelp.config;

import cn.wenlihelp.interceptors.AuthenticationInterceptor;
import cn.wenlihelp.interceptors.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Resource
    private LoginInterceptor loginInterceptor;

    @Resource
    private AuthenticationInterceptor authenticationInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        {
            InterceptorRegistration interceptor = registry.addInterceptor(loginInterceptor);
            interceptor.addPathPatterns("/**");
        }
        {
            InterceptorRegistration interceptor = registry.addInterceptor(authenticationInterceptor);
            interceptor.addPathPatterns("/**");
        }
    }
}
